<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // delay:秒
      function timeout(delay) {
        return new Promise((resolve, reject) => {
          setTimeout(() => {
            resolve(`延迟了${delay}秒`)
          }, delay * 1000)
        })
      }

      timeout(1)
        .then((res) => {
          console.log(res) // 1
          return timeout(2)
        })
        .then((res) => {
          console.log(res) // 2
          return timeout(3)
        })
        .then((res) => {
          console.log(res) // 3
        })
    </script>
  </body>
</html>
